import React, { Component } from 'react';
import { Form, Input, InputNumber, Button, DatePicker } from 'antd';
import { addDataList } from '../../api'
import { getDataList } from '../../store/actions'
class Index extends Component {
	async handleSubmit(value) {
		value.user.createAtTime = value.user.createAtTime.format('YYYY-MM-DD')
		const resp = await addDataList(value.user)
		const { code } = resp.data
		code === 200 && alert('添加成功')
	}
	render() {
		return (
			<div style={{
				width: 600,
				margin: 'auto'
			}}>
				<Form name="nest-messages"
					labelCol={{
						span: 4,
					}}
					wrapperCol={{
						span: 14,
					}}
					onFinish={value => this.handleSubmit(value)}
				>
					<Form.Item name={['user', 'nickname']} label="昵称">
						<Input />
					</Form.Item>
					<Form.Item name={['user', 'createAtTime']} label="创建日期">
						<DatePicker />
					</Form.Item>
					<Form.Item name={['user', 'desc']} label="描述">
						<Input.TextArea />
					</Form.Item>
					<Form.Item wrapperCol={{ offset: 4 }}>
						<Button type="primary" htmlType="submit">
							Submit
						</Button>
					</Form.Item>
				</Form>
			</div>
		);
	}
}

export default Index;
